// 基于template/src/widgets/{{appEntities}}/{{ctrls@GRID}}-grid/{{spinalCase ctrl.codeName}}-grid-model.ts.hbs生成
import { IGridModel, IParam, isEmpty, VerifyUtil } from '@/core';

function getModel(): IGridModel {
	return {
		cssName: '',
		aggMode: 'NONE',
		caption: '',
		controlType: 'GRID',
		codeName: 'Usr0301287977',
		columns: getGridColumns(),
		dataItems: getGridDataItems(),
		dataExport: getDataExport(),
		enableRowEdit: false,
		entityCodeName: 'Sys_organization',
		entityLogicName: '组织机构',
		createDefaultItems: getCreateDefaultItems(),
		updateDefaultItems: getUpdateDefaultItems(),
		name: 'grid',
		noSort: false,
		rules: {
			//	静态值规则
			staticRules: {},
			//	编辑项值规则
			editRules: [],
		},
		showHeader: true,
		sortDir: '',
		sortField: '',
		limit: 20,
		dataImport: {
			codeName: 'DataImport',
			ignoreError: false,
			importItems: [
				{
					name: 'id',
					caption: App.ts('', '标识'),
					fieldCodeName: 'id',
				},
				{
					name: 'organization_name',
					caption: App.ts('', '名称'),
					fieldCodeName: 'organization_name',
				},
				{
					name: 'enabled',
					caption: App.ts('', '逻辑有效标记'),
					codeListTag: 'YesNo',
					fieldCodeName: 'enabled',
				},
				{
					name: 'creator',
					caption: App.ts('DEF.LNAME.CREATOR', '创建人'),
					fieldCodeName: 'creator',
				},
				{
					name: 'create_time',
					caption: App.ts('DEF.LNAME.CREATE_TIME', '创建时间'),
					fieldCodeName: 'create_time',
				},
				{
					name: 'updater',
					caption: App.ts('DEF.LNAME.UPDATER', '最后更新人'),
					fieldCodeName: 'updater',
				},
				{
					name: 'update_time',
					caption: App.ts('DEF.LNAME.UPDATE_TIME', '最后更新时间'),
					fieldCodeName: 'update_time',
				},
				{
					name: 'dc',
					caption: App.ts('DEF.LNAME.DC', 'DC'),
					fieldCodeName: 'dc',
				},
				{
					name: 'parent_id',
					caption: App.ts('', '上级组织机构标识'),
					fieldCodeName: 'parent_id',
				},
				{
					name: 'parent_name',
					caption: App.ts('', '上级名称'),
					fieldCodeName: 'parent_name',
				},
				{
					name: 'organization_number',
					caption: App.ts('', '机构编号'),
					fieldCodeName: 'organization_number',
				},
				{
					name: 'description',
					caption: App.ts('', '描述'),
					fieldCodeName: 'description',
				},
				{
					name: 'short_name',
					caption: App.ts('', '简称'),
					fieldCodeName: 'short_name',
				},
				{
					name: 'sort',
					caption: App.ts('', '排序'),
					fieldCodeName: 'sort',
				},
				{
					name: 'children',
					caption: App.ts('', '下级单位'),
					fieldCodeName: 'children',
				},
				{
					name: 'parent_ids',
					caption: App.ts('', '上级标识'),
					fieldCodeName: 'parent_ids',
				},
				{
					name: 'sub_ids',
					caption: App.ts('', '下级标识'),
					fieldCodeName: 'sub_ids',
				},
			],
		},
		paging: {
			defaultPageSize: 20,
		},
		uiEngineModel: [
			{
				name: 'engine_grid',
				triggerType: 'CTRLEVENT',
				logicType: 'APPVIEWENGINE',
				eventNames: 'ROWDBLCLICK;SELECTIONCHANGE;REMOVE;LOAD;BEFORELOAD',
				scriptCode: ``,
				entityCodeName: '',
				logicName: ``,
			},
		],
	};
}
//  获取所有表格列模型
function getGridColumns(): IParam[] {
	return [
		{
			align: 'left',
			codeName: 'organization_number',
			caption: '机构编号',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'organization_number',
			dataIndex: 'organization_number',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '机构编号',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'organization_number',
			width: 200,
			minWidth: 200,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'organization_name',
			caption: '名称',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'organization_name',
			dataIndex: 'organization_name',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '名称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'organization_name',
			minWidth: 250,
			width: 250,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'short_name',
			caption: '简称',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'short_name',
			dataIndex: 'short_name',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '简称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'short_name',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'parent_name',
			caption: '上级名称',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'parent_name',
			dataIndex: 'parent_name',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '上级名称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'parent_name',
			width: 250,
			minWidth: 250,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'center',
			codeName: 'uagridcolumn1',
			caption: '操作',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'UAGRIDCOLUMN',
			dataItemName: 'uagridcolumn1',
			dataIndex: 'uagridcolumn1',
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: false,
			excelCaption: '',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'uagridcolumn1',
			width: 220,
			minWidth: 220,
			resizable: true,
			valueFormat: '',
			uIActionDetails: [
				{
					name: 'u0ba329a',
					caption: '编辑',
					showIcon: true,
					showCaption: true,
					separator: false,
					uIActionTag: 'Edit',
					noPrivDisplayMode: 2,
					dataAccessAction: '',
					actionTarget: 'SINGLEKEY',
					uIActionMode: 'SYS',
					disabled: false,
					visible: true,
					logic: {
						name: 'grid_uagridcolumn1_u0ba329a_click',
						actionTag: 'Edit',
						actionDECodeName: 'Sys_organization',
						predefinedType: 'GRIDVIEW_EDITACTION',
					},
					iconClass: 'fa fa-edit',
				},
				{
					name: 'u5536219',
					caption: '管理',
					showIcon: true,
					showCaption: true,
					separator: false,
					uIActionTag: 'ManageOrg',
					noPrivDisplayMode: 2,
					dataAccessAction: '',
					actionTarget: 'SINGLEKEY',
					uIActionMode: 'FRONT',
					disabled: false,
					visible: true,
					logic: {
						name: 'grid_uagridcolumn1_u5536219_click',
						actionTag: 'ManageOrg',
						actionDECodeName: 'Sys_organization',
						predefinedType: '',
					},
					iconClass: 'fa fa-sitemap',
				},
			],
		},
	];
}

//  获取所有表格数据项
function getGridDataItems() {
	return [
		{
			name: 'organization_number',
			codeName: '',
			customCode: false,
			fieldCodeName: 'organization_number',
			fieldName: 'organization_number',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'organization_name',
			codeName: '',
			customCode: false,
			fieldCodeName: 'organization_name',
			fieldName: 'organization_name',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'short_name',
			codeName: '',
			customCode: false,
			fieldCodeName: 'short_name',
			fieldName: 'short_name',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'parent_name',
			codeName: '',
			customCode: false,
			fieldCodeName: 'parent_name',
			fieldName: 'parent_name',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'srfkey',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'id',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'srfdataaccaction',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'id',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'parent_id',
			codeName: '',
			customCode: false,
			fieldCodeName: 'parent_id',
			fieldName: 'parent_id',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'srfmajortext',
			codeName: '',
			customCode: false,
			fieldCodeName: 'organization_name',
			fieldName: 'organization_name',
			valueFormat: '',
			dataType: '25',
		},
	];
}

function getDataExport() {
	return {
		default: true,
		codeName: 'default',
		enableFront: true,
		fileName: '组织机构',
		exportItems: [
			{
				name: 'organization_number',
				label: '机构编号',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'organization_name',
				label: '名称',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'short_name',
				label: '简称',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'parent_name',
				label: '上级名称',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
		],
	};
}

function getCreateDefaultItems() {
	return [];
}

function getUpdateDefaultItems() {
	return [];
}

export const model = getModel();
